#include "WProgram.h"
int servoPin = 12;	

int minPulse = 500;   
int maxPulse = 2500;  
int pulse = minPulse;	 

// the time in milliseconds of last pulse
int lastPulse = 0;   
int refreshTime = 20; 

int analogValue = 0;  
int analogPin = 2;    

void setup() {
  pinMode(servoPin, OUTPUT);  
  pulse = minPulse;		
}

void loop() {   
  
  // pulse the servo again if rhe refresh time (20 ms) have passed:
  if (millis() - lastPulse >= refreshTime) {
    digitalWrite(servoPin, HIGH);   
    delayMicroseconds(pulse);	
    
    
    digitalWrite(servoPin, LOW);    
    
    
    // save the time of the last pulse
    lastPulse = millis();	    
  }
  delay(10);
  pulse = pulse + 1;
}
